<?php
    require_once dirname(dirname(__FILE__)) . '/config/config.php';
    require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_general.php';
    require_once DOCUMENT_ROOT . DIR_SHARED_LIBRARIES . 'lib_date.php';

    /**
     * Class api_about_us
     * @author Viet Anh
     */
    class api_contact
    {
        public static function get_contact()
        {
            $dao_general = new dao_general();

            $email   = $dao_general->get_option_value('contact_email');
            $phone = $dao_general->get_option_value('contact_phone');

            $about_us = array('email' => $email, 'phone' => $phone);

            return $about_us;
        }

        public static function set_contact($email, $phone)
        {
            $dao_general = new dao_general();

            $dao_general->set_option_value('contact_email', $email);
            $dao_general->set_option_value('contact_phone', $phone);

            return TRUE;
        }
        
        public static function validate_contact($email, $phone) {
            $error_show = "";
            if (empty($email)) {
                $error_show .= "Vui lòng điền Email";
            } else if (empty($email)) {
                $error_show .= "Vui lòng điền Số điện thoại";
            } else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                $error_show .= "Email không hợp lệ.";
            }
            return $error_show;
        }
    }